package com.c.ctgproject.fragment.review.car

import androidx.lifecycle.LiveData
import androidx.lifecycle.MutableLiveData
import com.c.ctgproject.base.BaseViewModel
import com.c.ctgproject.http.ApiMethods
import com.c.ctgproject.mode.MyConstants
import com.c.ctgproject.utils.*


class WaitCarViewModel :BaseViewModel(){
    private val mResult = MutableLiveData<String>()
    val result: LiveData<String> get() = mResult


    private val mConfirmOrder = MutableLiveData<String>()
    val confirmOrder: LiveData<String> get() = mConfirmOrder

    fun getList(page: Int, size: Int) {
        launch({
            mResult.value = ApiMethods.getApiService().reviewCarsList(
                userToken,
                handlerBody(
                    "isPass" to  MyConstants.UN_REVIEWED,
                    "pageNum" to page,
                    "pageSize" to size
                )
            ).awaitSync()
        }, {
            mError.value = it.message.toString()
        })
    }


    //报废车价格审核
    fun orderConfirm(msg: String, isPass: Int, orderId: Int) {
        launch({
            MyLog.d("请求了")
            mConfirmOrder.value = ApiMethods.getApiService().changeCarStatus(
                userToken, handlerBody("isPass" to isPass, "auditRemark" to msg, "applicationId" to orderId)
            ).awaitSync()
        }, {
            mError.value = it.message.toString()
        })
    }
}